//
//  LoginVC.m
//  DiningCar-Business
//
//  Created by 吕晶 on 2020/4/8.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "LoginVC.h"

@interface LoginVC ()

@property (nonatomic, strong) UITextField *nameField;
@property (nonatomic, strong) UITextField *pwdField;
@property (nonatomic, strong) UIButton *showBtn;
@property (nonatomic, strong) UIButton *loginBtn;

@end

@implementation LoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configUI];
}

- (void)configUI {
    self.view.backgroundColor = [UIColor whiteColor];
    UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(40, NaviHeight + 30, ScreenW - 80, 32)];
    titleLab.text = @"餐车商户端登录";
    titleLab.textColor = HexColor(0x2B2C44);
    titleLab.font = BoldFontOfSize(30);
    [self.view addSubview:titleLab];
    
    UILabel *nameTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(40, titleLab.nim_bottom + 60, titleLab.nim_width, 13)];
    nameTitleLab.text = @"账号";
    nameTitleLab.font = [UIFont systemFontOfSize:12];
    nameTitleLab.textColor = HexColor(0x2B2C44);
    [self.view addSubview:nameTitleLab];
    
    self.nameField = [[UITextField alloc] initWithFrame:CGRectMake(40, nameTitleLab.nim_bottom + 2, nameTitleLab.nim_width, 40)];
    self.nameField.placeholder = @"请输入用户名或手机号";
    self.nameField.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:self.nameField];
    
    UILabel *line1 = [[UILabel alloc] initWithFrame:CGRectMake(40, self.nameField.nim_bottom, self.nameField.nim_width, 1)];
    line1.backgroundColor = HexColor(0xF2F2F5);
    [self.view addSubview:line1];
    
    UILabel *pwdTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(40, line1.nim_bottom + 20, titleLab.nim_width, 13)];
    pwdTitleLab.text = @"密码";
    pwdTitleLab.font = [UIFont systemFontOfSize:12];
    pwdTitleLab.textColor = HexColor(0x2B2C44);
    [self.view addSubview:pwdTitleLab];
    
    self.pwdField = [[UITextField alloc] initWithFrame:CGRectMake(40, pwdTitleLab.nim_bottom + 2, pwdTitleLab.nim_width, 40)];
    self.pwdField.placeholder = @"请输入登录密码";
    self.pwdField.font = [UIFont systemFontOfSize:16];
    self.pwdField.secureTextEntry = YES;
    [self.view addSubview:self.pwdField];
    
    self.showBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 18, 18)];
    [self.showBtn setImage:[UIImage imageNamed:@"pwd_show"] forState:0];
    [self.showBtn addTarget:self action:@selector(showBtnClick) forControlEvents:UIControlEventTouchUpInside];
    self.pwdField.rightView = self.showBtn;
    self.pwdField.rightViewMode = UITextFieldViewModeAlways;
    
    UILabel *line2 = [[UILabel alloc] initWithFrame:CGRectMake(40, self.pwdField.nim_bottom, self.pwdField.nim_width, 1)];
    line2.backgroundColor = HexColor(0xF2F2F5);
    [self.view addSubview:line2];
    
    self.loginBtn = [[UIButton alloc] initWithFrame:CGRectMake(40, line2.nim_bottom + 40, line2.nim_width, 44)];
    [self.loginBtn setBackgroundColor:HexColor(0x2B2C44)];
    self.loginBtn.layer.cornerRadius = 6;
    [self.loginBtn setTitle:@"登录" forState:0];
    [self.loginBtn setTitleColor:[UIColor whiteColor] forState:0];
    [self.view addSubview:self.loginBtn];
}

- (void)showBtnClick {
    self.pwdField.secureTextEntry = !self.pwdField.isSecureTextEntry;
    [self.showBtn setImage:[UIImage imageNamed:self.pwdField.isSecureTextEntry ? @"pwd_show" : @"pwd_hide"] forState:0];
}

@end
